import 'package:flutter/animation.dart';
import 'package:flutter/material.dart';

//todo  下次尝试pageview的PageController事怎么使用生成轮播图的.....
class LogoApp extends StatefulWidget {
  _LogoAppState createState() => new _LogoAppState();
}

class _LogoAppState extends State<LogoApp> with SingleTickerProviderStateMixin {
  final _controller = new PageController();
  static const _kDuration = const Duration(milliseconds: 300);
  static const _kCurve = Curves.ease;
  final ValueChanged<int> opPaseleted = (int i){print(i);};
  Animation<double> animation;
  List<String> _urls = [
    'https://img.bosszhipin.com/beijin/mcs/chatphoto/20170725/861159df793857d6cb984b52db4d4c9c.jpg',
    'https://img2.bosszhipin.com/mcs/chatphoto/20151215/a79ac724c2da2a66575dab35384d2d75532b24d64bc38c29402b4a6629fcefd6_s.jpg',
    'https://img.bosszhipin.com/beijin/mcs/chatphoto/20180207/c15c2fc01c7407b98faf4002e682676b.jpg'
  ];
  Widget build(BuildContext context) {
    return new Stack(children: <Widget>[
      new PageView.builder(
        physics: new AlwaysScrollableScrollPhysics(),
        controller: _controller,
        itemBuilder: (BuildContext context, int index) {
          return new ConstrainedBox(
            constraints: const BoxConstraints.expand(),
            child: new Image.network(
              _urls[index % _urls.length],
              fit: BoxFit.cover,
              height: 50.0,
            ),
          );
        },
      ),

      new Positioned(
        bottom: 0.0,
        left: 0.0,
        child: new Material(
          color: Colors.blue,
          type: MaterialType.circle,
          child: new Row(
            children:<Widget>[
              new Container(
                width: 20.0,
                height: 20.0,
                child: new InkWell(
                  onTap: () {opPaseleted(1);},
                ),
              ),
              new Container(
                width: 20.0,
                height: 20.0,
                child: new InkWell(
                  onTap: () {opPaseleted(2);},
                ),
              ),
            ],
          )
        ),
      )
    ]);
  }

  dispose() {
    _controller.dispose();
    super.dispose();
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new LogoApp(),
    );
  }
}
